<?php
require_once 'common/init.php';
require_once 'config/conf.inc.php';

function main()
{
	global $tpl;
	
	$login_user = LoginManager::get_login_user();
	if (empty($login_user))
	{
		$tpl->assign("login_status", LOGINSTATUS_OFF);
	}
	else
	{
		$tpl->assign("login_status", LOGINSTATUS_ON);
		$tpl->assign("login_user", $login_user);
	}
	
	$action = $_POST['act'];
	$user = $_POST['username'];
	$pass = $_POST['password'];
	$tpl->assign("action", $action);
	
	if ($action == "act_login")
	{
		$ret = AccountManager::check_login($user, $pass, USERTYPE_OWN, $err);
		$tpl->assign("is_login", $ret);
		
		if ($ret == USERSTATUS_USE)
		{
			LoginManager::set_login($user);
		}
	}
	
	$ret = $tpl->display('login.html');
}

main();


?>